package shanghaielectric.com.shanghaielectric;

/**
 * Created by cuihanbing on 2017/10/24.
 */

public class EnumDataHelper {
    public enum POINT_DATETYPE {
        ENUM("ENUM", 1),//枚举量
        COMCALC("COMCALC", 2),//普通模拟量
        BOOL("BOOL", 3),//开关量
        TIME("TIME", 4),//时间量
        CALC("CALC", 5),//计算量
        INT("INT",6),
        DOUBLE("DOUBLE",7),
        ENUM_BIT("ENUM_BIT", 8);//枚举量
        private String name;
        private int index;

        private POINT_DATETYPE(String name, int index) {
            this.name = name;
            this.index = index;
        }

        public static String getName(int index) {
            for (POINT_DATETYPE p : POINT_DATETYPE.values()) {
                if (p.getIndex() == index) {
                    return p.name;
                }
            }
            return null;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }
    }


    public enum PROTOCOL_TYPE {
        TCP("TCP", 1), RTU("RTU", 2), _104("_104", 3);
        private String name;
        private int index;

        private PROTOCOL_TYPE(String name, int index) {
            this.name = name;
            this.index = index;
        }

        public static String getName(int index) {
            for (PROTOCOL_TYPE p : PROTOCOL_TYPE.values()) {
                if (p.getIndex() == index) {
                    return p.name;
                }
            }
            return null;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }
    }


    public enum MODBUS_DATA_TYPE {

        READ_SHORT("READ_SHORT", 1),
        READ_WRITE_SHORT("READ_WRITE_SHORT", 2),
        READ_CHAR("READ_CHAR", 3),
        READ_WRITE_CHAR("READ_WRITE_CHAR", 4),
        READ_INT("READ_INT", 5),
        READ_WRITE_INT("READ_WRITE_INT", 6),
        READWRITE_BOOL("READWRITE_BOOL", 7),
        READ_BOOL("READ_BOOL", 8);

        private String name;
        private int index;

        private MODBUS_DATA_TYPE(String name, int index) {
            this.name = name;
            this.index = index;
        }

        public static String getName(int index) {
            for (MODBUS_DATA_TYPE c : MODBUS_DATA_TYPE.values()) {
                if (c.getIndex() == index) {
                    return c.name;
                }
            }
            return null;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }
    }

    public enum READ_WRITE_TYPE {
        READ("READ", 1),
        WRITE("WRITE", 2);

        private String name;
        private int index;

        private READ_WRITE_TYPE(String name, int index) {
            this.name = name;
            this.index = index;
        }

        public static String getName(int index) {
            for (READ_WRITE_TYPE p : READ_WRITE_TYPE.values()) {
                if (p.getIndex() == index) {
                    return p.name;
                }
            }
            return null;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }
    }

    public enum DATA_VALUE_TYPE {
        BASIC("BASIC", 1),
        BITLIST("BITLIST", 2);

        private String name;
        private int index;

        private DATA_VALUE_TYPE(String name, int index) {
            this.name = name;
            this.index = index;
        }

        public static String getName(int index) {
            for (DATA_VALUE_TYPE p : DATA_VALUE_TYPE.values()) {
                if (p.getIndex() == index) {
                    return p.name;
                }
            }
            return null;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }
    }

  public    enum  PUSH_TYPE {
        COMM_TYPE ,  SETTING_TIME

    }

}
